#-------------------------------[知乎：叶枝黎曼]-------------------------
def preP(index):
    global s
    for t in range(index):
        if n <= 1:
            return
        for i in range(n - 2, - 1,- 1):
            if s[i] > s[i + 1]:
                for j in range(n - 1,-1,-1):
                    if s[j] < s[i]:
                        s[j],s[i] = s[i],s[j]
                        s[i + 1:] = sorted(s[i + 1:],reverse = True)
                        break
                break
            else:
                if i == 0:
                    s = sorted(s,reverse = True)


n = int(input())
index = int(input())
s = [int(i) for i in input().split()]

preP(index)

print(' '.join(map(str,s)))
